<template>
	<view style="min-height: 100vh; background: linear-gradient(180deg, #e2e5f3, #fff 30%)">
		<view v-if="fl != 'zhiyin'" class="">
			<view style="background-color: transparent; border-radius: 10px">
				<view class="u-content">
					<center
						style="margin-bottom: 10px; font-size: 16px; font-weight: bold; color: rgb(29, 31, 32); text-align: left"
					>
						{{ tit }}
					</center>
					<view v-if="type && type == 'notice'" class="time-wrap" style="margin-bottom: 5px">
						<view v-if="noticeDetail" class="time" style="margin-bottom: 13px; color: #666; font-size: 12px">
							{{ noticeDetail.send_time }}
						</view>
					</view>
					<u-parse :content="content" :selectable="true"></u-parse>
				</view>
			</view>
		</view>
		<view v-else class="">
			<view class="" :style="[{ height: windowHeight }, { width: windowWidth }]">
				<view class="" :style="[{ height: windowHeight }, { width: windowWidth }]">
					<swiper
						:current="current"
						@animationfinish="annn"
						class="swiper"
						style="width: 100%; height: 100%"
						:circular="false"
						:autoplay="false"
						:interval="500"
						:duration="500"
					>
						<swiper-item @click="qieh(it, index)" v-for="(it, index) in list1" :key="index">
							<image style="width: 100%; height: 100%" :src="it" mode=""></image>
						</swiper-item>
					</swiper>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import config from '../../common/config/index.js';
	export default {
		data() {
			return {
				noticeDetail: null,
				content: '',
				tit: '',
				type: '',
				fl: '',
				windowHeight: '',
				windowWidth: '',
				imgurl: config.imgurl,
				list1: [],
				number: '',
				asd: 0,
				current: 0,
				fl: '',
			};
		},
		onLoad(e) {
			let that = this;
			uni.getSystemInfo({
				success(res) {
					that.windowHeight = res.windowHeight + 'px';
					that.windowWidth = res.windowWidth + 'px';
				},
			});
			this.fl = e.fl;
			this.all = e.all;
			this.type = e.type;
			if (this.type == 'notice') {
				this.nodetils(e.id);
			} else {
				this.detail(e.id);
			}
		},
		methods: {
			qieh(e, i) {
				this.current = this.current + 1;
			},
			annn(e) {
				// console.log(this.number);
				setTimeout(() => {
					if (e.detail.current == this.list1.length - 1) {
						uni.showToast({
							icon: 'none',
							title: '已到最后一页',
						});
						setTimeout(() => {
							uni.navigateBack({
								delta: 1,
							});
						}, 300);
					}
				}, 0);
			},
			change(e) {},
			async nodetils(e) {
				let res = await this.$http.index.noticeDetail({
					notice_id: e,
					is_myproject: 1,
				});
				if (res.code == 1) {
					this.noticeDetail = res.data;
					this.tit = res.data.title;
					this.content = res.data.content;
					console.log('type', res.data);
				}
			},
			async detail(id) {
				if (this.all == 'all') {
					let res = await this.$http.index.service();
					if (res.code == 1) {
						this.content = res.data;
					}
				} else {
					let res = await this.$http.car.articleContent({
						article_id: id,
					});
					if (res.code == 1) {
						this.tit = res.data.title;
						this.content = res.data.content;
						let a = {};
						res.data.pic.push(a);
						this.list1 = res.data.pic.map((it) => {
							return (it = this.imgurl + it);
						});
					}
				}
			},
		},
	};
</script>

<style>
	page {
		background-color: #f7f9fa;
	}

	.u-content {
		padding: 24rpx;
	}
</style>
